<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="utf-8" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="format-detection" content="email=no" />
	<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
	<title>图片上传</title>
 
	<script type="text/javascript" src="../../js/jquery.js"></script>
	<script type="text/javascript" src="../../js/jquery-form.js"></script>
	
	<link rel="stylesheet" type="text/css" href="../plugins/layer/need/layer.css" />
	<script type="text/javascript" src="../plugins/layer/layer.js"></script>
	
	<style type="text/css">
	
		.sure_btn { 
                width: 100px;
                height: 30px;
                line-height: 30px;
                text-align: center;
                background: #159ee2;
                color: #fff;
                font-size: 16px;
                margin: 20px 10px;
                float: left;
            }
	
	</style>
	<script type="text/javascript">
	    i = 1;  
	    j = 1;  
	    $(document).ready(function(){          
	        $("#btn_add").click(function(){  
	            //'document.getElementById("newUpload").innerHTML+='<div id="div_'+j+'"><input  name="file_'+j+'" type="file"  /><input type="button" value="删除"  onclick="del_2('+j+')"/></div>';  
	              j = j + 1; 
	              var htmlStr = '<div style="margin: 10px 0px;" id="div_'+j+'"><input  name="file_'+j+'" type="file"  /><input type="button" value="删除"  onclick="del_2('+j+')"/></div>';
	              $('#newUpload').append(htmlStr);
	              
	        });  
	    });  
	      
	    function del_2(o){  
	        document.getElementById("newUpload").removeChild(document.getElementById("div_"+o));  
	    }
	    
	    function sumbitPic() {
	    	var account = $('#account').val();
            if(!account) {
                alert("淘宝帐号不能为空！");
                return;
            }
            layer.open({shadeClose: false,type: 2});
		    $("#userForm").ajaxSubmit({
		        //定义返回JSON数据，还包括xml和script格式
		        type: "POST",
		        dataType:'json',
		        url:"http://jgj.hzlingdian.com/jgj/coreTaobaoPic/upload",
		        //url:"http://127.0.0.1:8080/jgj/coreTaobaoPic/upload",
		        success: function(data) {
		        	layer.closeAll();
		        	if(!data.success) {
                        alert(data.errMsg);
                    }else{
                    	alert("上传成功");
                    	//window.location.reload();
                    	$('#account').val("");
                    	$('#newUpload').html('<input type="file" name="file" /> ');
                    	
                    }
		        }
		    });
		}
	</script>  
</head>  
<body>    
    <form id="userForm" name="userForm" action="coreTaobaoPic/upload" enctype="multipart/form-data" method="post"">  
                          淘宝账号：<input id="account" type="text" width="395px" name="account" />    
        <div id="newUpload"  style="margin: 10px 0px;">  
            <input type="file" name="file" />  
        </div>  
<!--         <input style="margin: 10px 0px;" type="button" id="btn_add" value="增加一行" >   -->
        <div id="btn_add" class="sure_btn")">增加一个文件</div>
         <div class="sure_btn" onclick="sumbitPic()">上传</div>        
    </form>   
</body>
  
</html>